﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using AvalonDock;

using FXnaGis;

using FXnaInfrastructure;

using GWApplication;

namespace GWPresentation
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            //我们暂时这样设置一下

            this.DataContext = AppViewModel.Current;




            CommandService.CurrentService.BindCommandsToWindow(this);

            CommandService.CurrentService.BindKeyToWindow(this);

            

            //完成一些界面的初始化

            FMap map = this.wfhGis.Child as FMap;


            GisService.CurrentService.CurrentMap = map;



            //需要做一些基本的设置,这里我们只是为了方便测试

            map.MouseMove += new System.Windows.Forms.MouseEventHandler(map_MouseMove);
            

        }


        void map_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            FMap map = this.wfhGis.Child as FMap;

            DotSpatial.Topology.Coordinate c= map.GeoMapFrame.BufferToProj(e.Location);

            lblCoordX.Content ="X:" +c.X.ToString("F02");

            lblCoordY.Content ="Y:"+ c.Y.ToString("F02");

        }


        /// <summary>
        /// 这只是个测试新技术的入口点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            FMap map = this.wfhGis.Child as FMap;

            

            FVectorLayer vectorLayer = new FVectorLayer("vector");

            FCircleShape cirle = new FCircleShape("1");




            FGridShape grid = new FGridShape("grid",new FGrid(0,0,0, 101,101,1000,1000));

            FContourShape cshape = new FContourShape("contour", new FGrid(0,0,0,101, 101, 1000, 1000));

            //vectorLayer.AddShape(cirle);

            vectorLayer.AddShape(grid);

            double[,] data = FileService.ReadTxtRaw(@"c:\test\1.txt");

            cshape.Data = data;
            cshape.SetContourLines(new List<ContourLine> { new ContourLine(37,System.Drawing.Color.Red),new ContourLine(51,System.Drawing.Color.PowderBlue)});

            vectorLayer.AddShape(cshape);




            //我们先测试一些缩放到最大值

           

            map.GeoMapFrame.LayerService.Add(vectorLayer);
            //map.GeoMapFrame.DrawingLayers.Add(contour);


            map.ZoomToMaxExtent();







        }
    }
}
